package com.directv.z8training.ex6;

/**
 * @author HieuLT8
 *
 */
public class Person implements Comparable<Person> {
	protected int id;
	protected String name;
	protected String address;
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	protected int age;
	
	public Person(int id, String name, String address, int age) {
		this.id = id;
		this.name = name;
		this.address = address;
		this.age = age;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null){
			return false;
		} if (! (obj instanceof Person)){
			return false;
		} 
		
		Person other = (Person) obj;
		return this.name.equals(other.name);
	}
	
	@Override
	public int hashCode() {
		return this.name.hashCode();
	}

	@Override
	public int compareTo(Person o) {
		return o.name.compareTo(this.name);
	}
}
